import {
    Object3D, GridHelper, AxesHelper, LineBasicMaterial, Color
} from "three";

export default class Axis {

    public grid: GridHelper;//栅格辅助对象
    public axes: AxesHelper;//坐标轴辅助对象
    private _visible: boolean = true;

    public constructor(obj: Object3D, size: number = 2, depth = true) {
        const axis = new AxesHelper();
        const axesMat = axis.material as LineBasicMaterial;
        axesMat.depthTest = false;
        obj.add(axis);

        const grid = new GridHelper(size);
        const gridMat = grid.material as LineBasicMaterial;
        gridMat.depthTest = depth;
        obj.add(grid);

        this.axes = axis;
        this.grid = grid;
    }

    public get visible() {
        return this._visible;
    }

    public set visible(val: boolean) {
        this._visible = val;
        this.grid!.visible = val;
        this.axes!.visible = val;
    }

}